<?php

namespace Admin\Controller;

class WidgetsController extends BaseController {

    //加载小部件
    public function index() {
        $widget = new \Common\Widget\SideBarWidget();
        $widgets = $widget->getAll();
        $this->assign('widgets', $widgets);
        $addedWidget = D('Options')->getByModule('widget', 1);
        foreach ($addedWidget as $k => $v) {
            $addedWidget[$k] = unserialize($v);
            $this->assign($addedWidget[$k]);
            $addedWidget[$k]['form']=$this->fetch('',$widgets[$k]['form']);
        }
        $this->assign('addedWidget',$addedWidget);
        $this->display();
    }
    
    public function save(){
        $post=I('post.');
        $widget = new \Common\Widget\SideBarWidget();
        $widget->save($post);
    }

}
